//
//  Bundle_Ex.swift
//  Dawn
//
//  Created by cuicheng on 2021/9/18.
//

import UIKit

extension Bundle {
    
    var name: String {
        let info = Bundle.main.infoDictionary
        return info?["CFBundleDisplayName"] as! String
    }
    
    var version: String {
        let info = Bundle.main.infoDictionary
        return info?["CFBundleShortVersionString"] as! String
    }
    
    var buildVersion: String {
        let info = Bundle.main.infoDictionary
        return info?["CFBundleVersion"] as! String
    }
    
    var icon: String {
        let info = Bundle.main.infoDictionary
        if let dict = info?["CFBundleIcons"] as? [String: Any],
           let primaryIcons = dict["CFBundlePrimaryIcon"] as? [String: Any],
            let iconFiles = primaryIcons["CFBundleIconFiles"] as? [Any] {
            return iconFiles.first as? String ?? ""
        }
        return ""
    }
}
